import sys
from PyQt5.QtWidgets import QSlider, QApplication, QVBoxLayout, QHBoxLayout, QWidget, QLabel
from PyQt5.QtCore import Qt

class InversionControl(QWidget):
    def __init__(self):
        super().__init__()
        self.setup_ui()
    
    def setup_ui(self):
        layout = QVBoxLayout()
        
        # 正常方向
        self.normal_slider = QSlider(Qt.Horizontal)
        self.normal_slider.setRange(0, 100)
        self.normal_slider.setValue(50)
        
        # 反转方向
        self.inverted_slider = QSlider(Qt.Horizontal)
        self.inverted_slider.setRange(0, 100)
        self.inverted_slider.setValue(50)
        self.inverted_slider.setInvertedAppearance(True)  # 反转外观
        self.inverted_slider.setInvertedControls(True)    # 反转控制
        
        # 垂直方向反转示例
        self.vertical_normal = QSlider(Qt.Vertical)
        self.vertical_normal.setRange(0, 100)
        self.vertical_normal.setValue(50)
        
        self.vertical_inverted = QSlider(Qt.Vertical)
        self.vertical_inverted.setRange(0, 100)
        self.vertical_inverted.setValue(50)
        self.vertical_inverted.setInvertedAppearance(True)
        
        h_layout = QHBoxLayout()
        h_layout.addWidget(QLabel("正常水平:"))
        h_layout.addWidget(self.normal_slider)
        h_layout.addWidget(QLabel("反转水平:"))
        h_layout.addWidget(self.inverted_slider)
        
        v_layout = QHBoxLayout()
        v_layout.addWidget(QLabel("正常垂直:"))
        v_layout.addWidget(self.vertical_normal)
        v_layout.addWidget(QLabel("反转垂直:"))
        v_layout.addWidget(self.vertical_inverted)
        
        layout.addLayout(h_layout)
        layout.addLayout(v_layout)
        self.setLayout(layout)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = InversionControl()
    window.show()
    sys.exit(app.exec_())